﻿using System;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using HRM.HRMServiceProxy;

namespace HRM
{
    public partial class frmCandidate : Form
    {
        DialogResult dlgResult;

        CandidateInfo _CandidateInfo;
        CCInfo _CCInfo;
        CWBInfo _CWBInfo;
        CFamilyInfo _CFamilyInfo;
        CLanguageInfo _CLanguageInfo;
        CCriteriaInfo _CCriteriaInfo1;
        CCriteriaInfo _CCriteriaInfo2;
        CCriteriaInfo _CCriteriaInfo3;
        CInterviewInfo _CInterviewInfo;

        CandidateClient _wcfCandidate;
        CCClient _wcfCC;
        CWBClient _wcfCWB;
        CFamilyClient _wcfCFamily;
        CLanguageClient _wcfCLanguage;
        CCriteriaClient _wcfCCriteria;
        CInterviewClient _wcfCInterview;

        RoleRightInfo listRole;
        public frmCandidate(int CandidateID, RoleRightInfo _listRole, int _status)
        {
            InitializeComponent();
            this.KeyPreview = true;
            dlgResult = DialogResult.Cancel;          
            LoadLanguage();
            try
            {
                _wcfCandidate = Service.Candidate();
                _wcfCC = Service.CC();
                _wcfCWB = Service.CWB();
                _wcfCFamily = Service.CFamily();
                _wcfCLanguage = Service.CLanguage();
                _wcfCCriteria = Service.CCriteria();
                _wcfCInterview = Service.CInterview();

                _CandidateInfo = new CandidateInfo();
                _CCInfo = new CCInfo();
                _CWBInfo = new CWBInfo();
                _CFamilyInfo = new CFamilyInfo();
                _CLanguageInfo = new CLanguageInfo();
                _CCriteriaInfo1 = new CCriteriaInfo();
                _CCriteriaInfo2 = new CCriteriaInfo();
                _CCriteriaInfo3 = new CCriteriaInfo();
                _CInterviewInfo = new CInterviewInfo();
                LoadStandard();

                txtCode.Text = _wcfCandidate.Candidate_AutoCreateCode().No;

                UISetting.LoadMeritalStatus(ref cboMaritalStatus);
                UISetting.LoadReligion(ref cboReligion);
                UISetting.LoadEthnic(ref cboEthlic);
                UISetting.LoadAbility(ref mcbCLanguage_SelfRating);
                UISetting.LoadAbility(ref mcbCLanguage_CommentsOfInterview);

                if (_status == 1) //Nhập hồ sơ
                    btnSave.Enabled = false;
                else
                    btnSave.Enabled = true;

                listRole = _listRole;
                if (!listRole._create)
                    btnNew.Enabled = false;
                if (!listRole.Update)
                    btnSave.Enabled = false;
                if (CandidateID > 0)
                {
                    _CandidateInfo = _wcfCandidate.Candidate_GetInfo(CandidateID);



                    PersonalOut();


                }
                _CandidateInfo.ID = CandidateID;

                dgvCC.CellClick += new DataGridViewCellEventHandler(dgvCC1_CellClick);
                dgvCWB.CellClick += new DataGridViewCellEventHandler(dgvCWB1_CellClick);
                dgvCFamily.CellClick += new DataGridViewCellEventHandler(dgvCFamily1_CellClick);
                dgvCLanguage.CellClick += new DataGridViewCellEventHandler(dgvCLanguage1_CellClick);
                LoadData_CC();
                LoadData_CWB();
                LoadData_CFamily();
                LoadData_CLanguage();
            }
            catch (Exception ex)
            {
                MessageBox.Show(UpdateUI.GetString("loi") + ":\n" + ex.Message + "\n" + UpdateUI.GetString("ghiloi"));
            }
        }
        void LoadStandard()
        {
            StandardClient wcfStandard = Service.Standard();
            DataTable dt = wcfStandard.Standard_GetAll().Tables[0];
            DataRow dr = dt.NewRow();
            dr["Standard_ID"] = 0;
            dr["Standard_Name"] = "";
            dt.Rows.InsertAt(dr, 0);
            cboStandard.DataSource = null;
            cboStandard.DisplayMember = "Standard_Name";
            cboStandard.ValueMember = "Standard_ID";
            cboStandard.DataSource = dt;
        }
        #region Personal

        private void PersonalOut()
        {
            try
            {
                txtCode.Text = _CandidateInfo.No;
                txtFirstName.Text = _CandidateInfo.FirstName;
                txtLastName.Text = _CandidateInfo.LastName;
                txtAlias.Text = _CandidateInfo.Alias;
                cboStandard.SelectedValue = _CandidateInfo.Education;
                mtxBirthday.Text = _CandidateInfo.DateOfBirth.ToString("dd/MM/yyyy");
                txtBirthPlace.Text = _CandidateInfo.PlaceOfBirth;
                txtAddress.Text = _CandidateInfo.Address;
                txtPhone.Text = _CandidateInfo.Phone;

                rdnMale.Checked = _CandidateInfo.Sex;
                rdnFemale.Checked = !rdnMale.Checked;

                cboMaritalStatus.SelectedValue = Convert.ToInt32(_CandidateInfo.MaterialStatusID);
                cboEthlic.SelectedValue = Convert.ToInt32(_CandidateInfo.EthlicID);
                cboReligion.SelectedValue = Convert.ToInt32(_CandidateInfo.ReligionID);
                txtIDCardNo.Text = _CandidateInfo.IDCardNo;
                mtxIDCardIssueDate.Text = _CandidateInfo.IDCardIssueDate == DateTime.MinValue ? "" : Convert.ToDateTime(_CandidateInfo.IDCardIssueDate).ToString("dd/MM/yyyy");
                txtIDCardIssueAuthority.Text = _CandidateInfo.IDCardIssueAuthority;
                mtxDate.Text = _CandidateInfo.Date == DateTime.MinValue ? "" : Convert.ToDateTime(_CandidateInfo.Date).ToString("dd/MM/yyyy");

                if (_CandidateInfo.ResidentOfHaNoi == 1)
                    rdnResidentYes.Checked = true;
                else if (_CandidateInfo.ResidentOfHaNoi == 0)
                    rdnResidentNo.Checked = true;
                else
                {
                    rdnResidentYes.Checked = false;
                    rdnResidentNo.Checked = false;
                }

                cboTransport.Text = _CandidateInfo.TransportMeans;
                txtDescription.Text = _CandidateInfo.Description;
                mtxWhenAvailable.Text = _CandidateInfo.WhenAvailable == DateTime.MinValue ? "" : Convert.ToDateTime(_CandidateInfo.WhenAvailable).ToString("dd/MM/yyyy");
                txtMinSalaryExpected.Text = Convert.ToDecimal(_CandidateInfo.MinSalaryExpected).ToString("#,##0");
                if (_CandidateInfo.WorkOnShift == 1)
                    rdnWorkOnShiftYes.Checked = true;
                else if (_CandidateInfo.WorkOnShift == 0)
                    rdnWorkOnShiftNo.Checked = true;
                else
                {
                    rdnWorkOnShiftYes.Checked = false;
                    rdnWorkOnShiftNo.Checked = false;
                }

                chkSpecialSkill1.Checked = _CandidateInfo.SpecialSkill.Contains("Đánh máy") ? true : false;
                chkSpecialSkill2.Checked = _CandidateInfo.SpecialSkill.Contains("Sử dụng máy tính") ? true : false;
                chkSpecialSkill3.Checked = _CandidateInfo.SpecialSkill.Contains("Kỹ năng viết") ? true : false;
                chkSpecialSkill4.Checked = _CandidateInfo.SpecialSkill.Contains("Kỹ năng khác") ? true : false;

                if (_CandidateInfo.Acquaintance == 1)
                    rdnAcquaintanceY.Checked = true;
                else if (_CandidateInfo.Acquaintance == 0)
                    rdnAcquaintanceN.Checked = true;
                else
                {
                    rdnAcquaintanceY.Checked = false;
                    rdnAcquaintanceN.Checked = false;
                }



                txtAcquaintanceName.Text = _CandidateInfo.AcquaintanceName;


                if (_CandidateInfo.PartimeCourse == 1)
                    rdnPartimeCourseY.Checked = true;
                else if (_CandidateInfo.PartimeCourse == 0)
                    rdnPartimeCourseN.Checked = true;
                else
                {
                    rdnPartimeCourseY.Checked = false;
                    rdnPartimeCourseN.Checked = false;
                }


                txtCourseName.Text = _CandidateInfo.CourseName;
                txtCourseTime.Text = _CandidateInfo.CourseTime.ToString();

            }
            catch (Exception ex)
            {
                MessageBox.Show(UpdateUI.GetString("loi") + ":\n" + ex.Message + "\n" + UpdateUI.GetString("ghiloi"));
            }
        }
        private void PersonalIn()
        {
            try
            {
                _CandidateInfo.No = txtCode.Text.Trim();
                _CandidateInfo.FirstName = txtFirstName.Text.Trim();
                _CandidateInfo.LastName = txtLastName.Text.Trim();
                _CandidateInfo.Alias = txtAlias.Text.Trim();
                _CandidateInfo.Education = cboStandard.SelectedValue.ToString();
                _CandidateInfo.DateOfBirth = UISetting.GetDate(mtxBirthday.Text);
                _CandidateInfo.PlaceOfBirth = txtBirthPlace.Text;
                _CandidateInfo.Address = txtAddress.Text;
                _CandidateInfo.Phone = txtPhone.Text;
                _CandidateInfo.Sex = rdnMale.Checked;
                _CandidateInfo.MaterialStatusID = Convert.ToInt32(cboMaritalStatus.SelectedValue);
                _CandidateInfo.EthlicID = Convert.ToInt32(cboEthlic.SelectedValue);
                _CandidateInfo.ReligionID = Convert.ToInt32(cboReligion.SelectedValue);
                _CandidateInfo.IDCardNo = txtIDCardNo.Text;
                _CandidateInfo.IDCardIssueDate = UISetting.GetDate(mtxIDCardIssueDate.Text);
                _CandidateInfo.IDCardIssueAuthority = txtIDCardIssueAuthority.Text;
                _CandidateInfo.Date = UISetting.GetDate(mtxDate.Text);
                if (rdnResidentYes.Checked)
                    _CandidateInfo.ResidentOfHaNoi = 1;
                else if (rdnResidentNo.Checked)
                    _CandidateInfo.ResidentOfHaNoi = 0;
                else
                    _CandidateInfo.ResidentOfHaNoi = 2;
                _CandidateInfo.TransportMeans = cboTransport.Text;
                _CandidateInfo.Description = txtDescription.Text;
                _CandidateInfo.PositionID = 0;
                _CandidateInfo.DepartmentID = 0;
                _CandidateInfo.WhenAvailable = UISetting.GetDate(mtxWhenAvailable.Text);
                _CandidateInfo.MinSalaryExpected = UISetting.GetDecimalNo(txtMinSalaryExpected.Text);

                if (rdnWorkOnShiftYes.Checked)
                    _CandidateInfo.WorkOnShift = 1;
                else if (rdnWorkOnShiftNo.Checked)
                    _CandidateInfo.WorkOnShift = 0;
                else
                    _CandidateInfo.WorkOnShift = 2;

                _CandidateInfo.SpecialSkill = SetSpecialSkill();

                if (rdnAcquaintanceY.Checked)
                    _CandidateInfo.Acquaintance = 1;
                else if (rdnAcquaintanceN.Checked)
                    _CandidateInfo.Acquaintance = 0;
                else
                    _CandidateInfo.Acquaintance = 2;


                _CandidateInfo.AcquaintanceName = txtAcquaintanceName.Text;


                if (rdnPartimeCourseY.Checked)
                    _CandidateInfo.PartimeCourse = 1;
                else if (rdnPartimeCourseN.Checked)
                    _CandidateInfo.PartimeCourse = 0;
                else
                    _CandidateInfo.PartimeCourse = 2;

                _CandidateInfo.CourseName = txtCourseName.Text;
                _CandidateInfo.CourseTime = UISetting.GetIntNo(txtCourseTime.Text);
                _CandidateInfo.FinancialController = "";
                _CandidateInfo.SalaryDate = DateTime.MinValue;
                _CandidateInfo.ProbationStartDate = DateTime.MinValue;
                _CandidateInfo.ProbationPeriod = 0;
                _CandidateInfo.ProbationSalary = 0;
                _CandidateInfo.TraningSalary = 0;
                _CandidateInfo.ConfomationSalary = 0;
                _CandidateInfo.Others = "";
            }
            catch (Exception ex)
            {
                MessageBox.Show(UpdateUI.GetString("loi") + ":\n" + ex.Message + "\n" + UpdateUI.GetString("ghiloi"));
            }
        }
        string SetSpecialSkill()
        {
            string _str = "";
            if (chkSpecialSkill1.Checked)
                _str = "Đánh máy";
            if (chkSpecialSkill2.Checked)
                _str = _str == "" ? _str + "Sử dụng máy tính" : _str + ",Sử dụng máy tính";
            if (chkSpecialSkill3.Checked)
                _str = _str == "" ? _str + "Kỹ năng viết" : _str + ",Kỹ năng viết";
            if (chkSpecialSkill4.Checked)
                _str = _str == "" ? _str + "Kỹ năng khác" : _str + ",Kỹ năng khác";
            return _str;

        }
        private bool CheckValidPersonal()
        {
            if (txtCode.Text.Trim().Length == 0)
            {
                txtCode.Focus();
                MessageBox.Show(UpdateUI.GetString("masokhongduoctrong"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return false;
            }
            if (txtLastName.Text.Trim().Length == 0)
            {
                txtLastName.Focus();
                MessageBox.Show(UpdateUI.GetString("hotrong"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return false;
            }
            if (txtFirstName.Text.Trim().Length == 0)
            {
                txtFirstName.Focus();
                MessageBox.Show(UpdateUI.GetString("tentrong"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return false;
            }

            if (!rdnMale.Checked && !rdnFemale.Checked)
            {
                MessageBox.Show(UpdateUI.GetString("chuachongioitinh"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return false;
            }
            if (UISetting.GetDate(mtxBirthday.Text) == DateTime.MinValue)
            {
                mtxBirthday.Focus();
                MessageBox.Show(UpdateUI.GetString("ngaysinhkhonghople"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return false;
            }
            if (UISetting.GetDate(mtxIDCardIssueDate.Text) != DateTime.MinValue)
            {
                if (DateTime.Compare(UISetting.GetDate(mtxBirthday.Text), UISetting.GetDate(mtxIDCardIssueDate.Text)) >= 0)
                {
                    mtxIDCardIssueDate.Focus();
                    MessageBox.Show(UpdateUI.GetString("ngaycapphaimuonhonnaysinh"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return false;
                }
            }
            if (UISetting.GetDate(mtxDate.Text) == DateTime.MinValue)
            {
                mtxDate.Focus();
                MessageBox.Show(UpdateUI.GetString("ngaynophosokhonghople"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return false;
            }
            else
            {
                if (DateTime.Compare(UISetting.GetDate(mtxBirthday.Text), UISetting.GetDate(mtxDate.Text)) >= 0)
                {
                    mtxDate.Focus();
                    MessageBox.Show(UpdateUI.GetString("ngaynopphaimuonhongaysinh"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return false;
                }

            }


            return true;
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (CheckValidPersonal())
                {
                    PersonalIn();
                    if (_CandidateInfo.ID > 0)//update
                    {
                        if (!listRole.Update)
                        {
                            MessageBox.Show(UpdateUI.GetString("khongcoquyencapnhat"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                        if (_wcfCandidate.Candidate_Exist(_CandidateInfo.ID, txtCode.Text.Trim()))
                        {
                            MessageBox.Show(UpdateUI.GetString("masodatontai"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                        if (_wcfCandidate.Candidate_Update(_CandidateInfo))
                        {
                            Program.taskbarNotifier.Show(UpdateUI.GetString("thongbao"), UpdateUI.GetString("capnhatthanhcong"), UIParamater.TIME_MOVE_UP, UIParamater.TIME_SHOW, UIParamater.TIME_MOVE_DOWN);
                            dlgResult = DialogResult.OK;
                        }
                        else
                            MessageBox.Show(UpdateUI.GetString("capnhatkhongthanhcong"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        if (!listRole.Create)
                        {
                            MessageBox.Show(UpdateUI.GetString("khongcoquyenthemmoi"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                        if (_wcfCandidate.Candidate_Exist(_CandidateInfo.ID, txtCode.Text.Trim()))
                        {
                            MessageBox.Show(UpdateUI.GetString("masodatontai"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                        _CandidateInfo.ID = _wcfCandidate.Candidate_Insert(_CandidateInfo);
                        if (_CandidateInfo.ID > 0)
                        {
                            Program.taskbarNotifier.Show(UpdateUI.GetString("thongbao"), UpdateUI.GetString("themmoithanhcong"), UIParamater.TIME_MOVE_UP, UIParamater.TIME_SHOW, UIParamater.TIME_MOVE_DOWN);
                            dlgResult = DialogResult.OK;
                        }
                        else
                            MessageBox.Show(UpdateUI.GetString("themmoikhongthanhcong"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(UpdateUI.GetString("loi") + ":\n" + ex.Message + "\n" + UpdateUI.GetString("ghiloi"));
            }
        }
        private void btnNew_Click(object sender, EventArgs e)
        {
            if (!listRole.Create)
            {
                MessageBox.Show(UpdateUI.GetString("khongcoquyenthemmoi"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            _CandidateInfo.ID = 0;
            _CandidateInfo = new CandidateInfo();
            txtCode.Text = _wcfCandidate.Candidate_AutoCreateCode().No;
            txtFirstName.Text = "";
            txtLastName.Text = "";
            txtAlias.Text = "";
            mtxBirthday.Text = "";
            txtBirthPlace.Text = "";
            txtAddress.Text = "";
            txtPhone.Text = "";
            rdnMale.Checked = false;
            rdnFemale.Checked = false;
            cboMaritalStatus.SelectedIndex = 0;
            cboEthlic.SelectedIndex = 0;
            cboReligion.SelectedIndex = 0;
            txtIDCardNo.Text = "";
            mtxIDCardIssueDate.Text = "";
            txtIDCardIssueAuthority.Text = "";
            mtxDate.Text = "";
            rdnResidentYes.Checked = false;
            rdnResidentNo.Checked = false;
            cboTransport.Text = "";
            txtDescription.Text = "";
            mtxWhenAvailable.Text = "";
            txtMinSalaryExpected.Text = "0";
            rdnWorkOnShiftYes.Checked = false;
            rdnWorkOnShiftNo.Checked = false;
            chkSpecialSkill1.Checked = false;
            chkSpecialSkill2.Checked = false;
            chkSpecialSkill3.Checked = false;
            chkSpecialSkill4.Checked = false;
            rdnAcquaintanceY.Checked = false;
            rdnAcquaintanceN.Checked = false;
            txtAcquaintanceName.Text = "";
            rdnPartimeCourseY.Checked = false;
            rdnPartimeCourseN.Checked = false;
            txtCourseName.Text = "";
            txtCourseTime.Text = "0";
            dgvCC.Rows.Clear();
            dgvCWB.Rows.Clear();
            dgvCFamily.Rows.Clear();
            dgvCLanguage.Rows.Clear();
        }
        private void txtMinSalaryExpected_Leave(object sender, EventArgs e)
        {
            txtMinSalaryExpected.Text = UISetting.GetDecimalNo(txtMinSalaryExpected.Text).ToString("#,##0");
        }

        #endregion

        #region CC (Academic)

        int itemCount_CC = 0;
        int currPage_CC = 0;
        int pageSize = 100;

        private void LoadData_CC()
        {
            try
            {
                DataSet _ds = _wcfCC.CC_GetList(out itemCount_CC, _CandidateInfo.ID, currPage_CC, pageSize);
                dgvCC.Rows.Clear();
                for (int i = 0; i < _ds.Tables[0].Rows.Count; i++)
                {
                    dgvCC.Rows.Insert(i, 1);
                    dgvCC.Rows[i].Cells["CC_ID"].Value = _ds.Tables[0].Rows[i]["CC_ID"].ToString();
                    dgvCC.Rows[i].Cells["CC_RowNumber"].Value = _ds.Tables[0].Rows[i]["RowNumber"].ToString();
                    dgvCC.Rows[i].Cells["CC_Name"].Value = _ds.Tables[0].Rows[i]["CC_Name"].ToString();
                    dgvCC.Rows[i].Cells["CC_AuthorityIssue"].Value = _ds.Tables[0].Rows[i]["CC_AuthorityIssue"].ToString();
                    if (_ds.Tables[0].Rows[i]["CC_IssueDate"] != DBNull.Value)
                        dgvCC.Rows[i].Cells["CC_IssueDate"].Value = Convert.ToDateTime(_ds.Tables[0].Rows[i]["CC_IssueDate"]).ToString("dd/MM/yyyy");
                    else
                        dgvCC.Rows[i].Cells["CC_IssueDate"].Value = DateTime.MinValue;
                    if (_ds.Tables[0].Rows[i]["CC_FromDate"] != DBNull.Value)
                        dgvCC.Rows[i].Cells["CC_FromDate"].Value = Convert.ToDateTime(_ds.Tables[0].Rows[i]["CC_FromDate"]).ToString("dd/MM/yyyy");
                    else
                        dgvCC.Rows[i].Cells["CC_FromDate"].Value = DateTime.MinValue;
                    if (_ds.Tables[0].Rows[i]["CC_ToDate"] != DBNull.Value)
                        dgvCC.Rows[i].Cells["CC_ToDate"].Value = Convert.ToDateTime(_ds.Tables[0].Rows[i]["CC_ToDate"]).ToString("dd/MM/yyyy");
                    else
                        dgvCC.Rows[i].Cells["CC_ToDate"].Value = DateTime.MinValue;
                    dgvCC.Rows[i].Cells["CC_Grade"].Value = _ds.Tables[0].Rows[i]["CC_Grade"].ToString();
                    dgvCC.Rows[i].Cells["CC_Speciality"].Value = _ds.Tables[0].Rows[i]["CC_Speciality"].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(UpdateUI.GetString("loi") + ":\n" + ex.Message + "\n" + UpdateUI.GetString("ghiloi"));
            }
        }
        private bool CheckValidCC()
        {
            if (_CandidateInfo.ID == 0)
            {
                MessageBox.Show(UpdateUI.GetString("chualuuthongtincanhan"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return false;
            }
            if (txtCC_AuthorityIssue.Text.Trim().Length == 0)
            {
                txtCC_AuthorityIssue.Focus();
                MessageBox.Show(UpdateUI.GetString("tentruongtrong"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return false;
            }

            if (UISetting.GetDate(mtxCC_FromDate.Text) == DateTime.MinValue)
            {
                mtxCC_FromDate.Focus();
                MessageBox.Show(UpdateUI.GetString("ngaybatdaukhonghople"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return false;
            }
            if (UISetting.GetDate(mtxCC_ToDate.Text) == DateTime.MinValue)
            {
                mtxCC_FromDate.Focus();
                MessageBox.Show(UpdateUI.GetString("ngayketthuckhonghople"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return false;
            }
            else
            {
                if (DateTime.Compare(UISetting.GetDate(mtxCC_FromDate.Text), UISetting.GetDate(mtxCC_ToDate.Text)) >= 0)
                {
                    mtxCC_ToDate.Focus();
                    MessageBox.Show(UpdateUI.GetString("ngayketthucphaimuonhonngaybatdau"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return false;
                }
            }
            if (txtCC_Grade.Text.Trim().Length == 0)
            {
                txtCC_Grade.Focus();
                MessageBox.Show(UpdateUI.GetString("trinhdokhongduocdetrong"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return false;
            }
            return true;
        }
        private void btnCCNew_Click(object sender, EventArgs e)
        {
            _CCInfo.ID = 0;
            txtCC_AuthorityIssue.Text = "";
            txtCC_Grade.Text = "";
            mtxCC_IssueDate.Text = "";
            mtxCC_FromDate.Text = "";
            mtxCC_ToDate.Text = "";
            txtCC_Name.Text = "";
            txtCC_Speciality.Text = "";
            txtCC_AuthorityIssue.Focus();
        }
        private void btnCCSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (CheckValidCC())
                {
                    AccdemicIn();
                    if (_CCInfo.ID > 0)//update
                    {
                        if (!listRole.Update)
                        {
                            MessageBox.Show(UpdateUI.GetString("khongcoquyencapnhat"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                        if (_wcfCC.CC_Exist(_CCInfo.ID, _CCInfo.CandidateID, txtCC_AuthorityIssue.Text.Trim()))
                        {
                            MessageBox.Show(UpdateUI.GetString("datontai"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                        if (_wcfCC.CC_Update(_CCInfo))
                        {
                            Program.taskbarNotifier.Show(UpdateUI.GetString("thongbao"), UpdateUI.GetString("capnhatthanhcong"), UIParamater.TIME_MOVE_UP, UIParamater.TIME_SHOW, UIParamater.TIME_MOVE_DOWN);
                            LoadData_CC();
                        }
                        else
                            MessageBox.Show(UpdateUI.GetString("capnhatkhongthanhcong"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        if (!listRole.Create)
                        {
                            MessageBox.Show(UpdateUI.GetString("khongcoquyenthemmoi"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                        if (_wcfCC.CC_Exist(_CCInfo.ID, _CCInfo.CandidateID, txtCC_AuthorityIssue.Text.Trim()))
                        {
                            MessageBox.Show(UpdateUI.GetString("datontai"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                        _CCInfo.ID = _wcfCC.CC_Insert(_CCInfo);
                        if (_CCInfo.ID > 0)
                        {
                            Program.taskbarNotifier.Show(UpdateUI.GetString("thongbao"), UpdateUI.GetString("themmoithanhcong"), UIParamater.TIME_MOVE_UP, UIParamater.TIME_SHOW, UIParamater.TIME_MOVE_DOWN);
                            LoadData_CC();
                        }
                        else
                            MessageBox.Show(UpdateUI.GetString("themmoikhongthanhcong"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    dgvCC_CellClick(null, null);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(UpdateUI.GetString("loi") + ":\n" + ex.Message + "\n" + UpdateUI.GetString("ghiloi"));
            }
        }
        private void dgvCC1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (!listRole.Delete)
            {
                MessageBox.Show(UpdateUI.GetString("khongcoquyenxoa"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (e.RowIndex < 0 || e.ColumnIndex !=
                    dgvCC.Columns["CC_Command"].Index) return;
            int CCID = Convert.ToInt32(dgvCC.CurrentRow.Cells["CC_ID"].Value);
            if (MessageBox.Show(UpdateUI.GetString("bancochacchanxoa"), UIParamater.TitleProject, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                if (_wcfCC.CC_Delete(CCID))
                {
                    Program.taskbarNotifier.Show(UIParamater.TitleProject, UpdateUI.GetString("xoathanhcong"), UIParamater.TIME_MOVE_UP, UIParamater.TIME_SHOW, UIParamater.TIME_MOVE_DOWN);
                    LoadData_CC();
                }
                else
                {
                    MessageBox.Show(UpdateUI.GetString("xoakhongthanhcong"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            dgvCC_CellClick(null, null);
        }
        private void dgvCC_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dgvCC.SelectedRows.Count > 0)
            {
                int CCID = Convert.ToInt32(dgvCC.CurrentRow.Cells["CC_ID"].Value);
                _CCInfo.ID = CCID;
                ReadFromdgvCC();
                AccdemicOut();
            }
        }
        private void ReadFromdgvCC()
        {

            _CCInfo.AuthorityIssue = dgvCC.CurrentRow.Cells["CC_AuthorityIssue"].Value.ToString();
            _CCInfo.Grade = dgvCC.CurrentRow.Cells["CC_Grade"].Value.ToString();
            _CCInfo.IssueDate = dgvCC.CurrentRow.Cells["CC_IssueDate"].Value == DBNull.Value ? DateTime.MinValue :
               UISetting.GetDate(dgvCC.CurrentRow.Cells["CC_IssueDate"].Value.ToString());
            _CCInfo.FromDate = dgvCC.CurrentRow.Cells["CC_FromDate"].Value == DBNull.Value ? DateTime.MinValue :
               UISetting.GetDate(dgvCC.CurrentRow.Cells["CC_FromDate"].Value.ToString());
            _CCInfo.ToDate = dgvCC.CurrentRow.Cells["CC_ToDate"].Value == DBNull.Value ? DateTime.MinValue :
                UISetting.GetDate(dgvCC.CurrentRow.Cells["CC_ToDate"].Value.ToString());
            _CCInfo.Name = dgvCC.CurrentRow.Cells["CC_Name"].Value.ToString();
            _CCInfo.Speciality = dgvCC.CurrentRow.Cells["CC_Speciality"].Value.ToString();
        }
        private void dgvCC_SelectionChanged(object sender, EventArgs e)
        {
            if (dgvCC.SelectedRows.Count > 0)
            {
                int CCID = dgvCC.CurrentRow.Cells["CC_ID"].Value == null ? 0 : Convert.ToInt32(dgvCC.CurrentRow.Cells["CC_ID"].Value);
                if (CCID > 0)
                {
                    _CCInfo.ID = CCID;
                    ReadFromdgvCC();
                }
            }
            else
            {
                _CCInfo.ID = 0;
                _CCInfo.AuthorityIssue = "";
                _CCInfo.Grade = "";
                _CCInfo.IssueDate = DateTime.MinValue;
                _CCInfo.FromDate = DateTime.MinValue;
                _CCInfo.ToDate = DateTime.MinValue;
                _CCInfo.Name = "";
                _CCInfo.Speciality = "";
            }
            AccdemicOut();
        }
        private void AccdemicIn()
        {
            _CCInfo.CandidateID = _CandidateInfo.ID;
            _CCInfo.AuthorityIssue = txtCC_AuthorityIssue.Text;
            _CCInfo.Grade = txtCC_Grade.Text;
            _CCInfo.IssueDate = UISetting.GetDate(mtxCC_IssueDate.Text);
            _CCInfo.FromDate = UISetting.GetDate(mtxCC_FromDate.Text);
            _CCInfo.ToDate = UISetting.GetDate(mtxCC_ToDate.Text);
            _CCInfo.Name = txtCC_Name.Text;
            _CCInfo.Speciality = txtCC_Speciality.Text;
        }
        private void AccdemicOut()
        {
            txtCC_AuthorityIssue.Text = _CCInfo.AuthorityIssue;
            txtCC_Grade.Text = _CCInfo.Grade;
            mtxCC_IssueDate.Text = _CCInfo.IssueDate == DateTime.MinValue ? "" : Convert.ToDateTime(_CCInfo.IssueDate).ToString("dd/MM/yyyy");
            mtxCC_FromDate.Text = _CCInfo.FromDate == DateTime.MinValue ? "" : Convert.ToDateTime(_CCInfo.FromDate).ToString("dd/MM/yyyy");
            mtxCC_ToDate.Text = _CCInfo.ToDate == DateTime.MinValue ? "" : Convert.ToDateTime(_CCInfo.ToDate).ToString("dd/MM/yyyy");
            txtCC_Name.Text = _CCInfo.Name;
            txtCC_Speciality.Text = _CCInfo.Speciality;
        }
        #endregion

        #region CWB (Experience)

        int itemCount_CWB = 0;
        int currPage_CWB = 0;
        private void LoadData_CWB()
        {
            try
            {
                DataSet _ds = _wcfCWB.CWB_GetList(out itemCount_CWB, _CandidateInfo.ID, currPage_CWB, pageSize);
                dgvCWB.Rows.Clear();
                for (int i = 0; i < _ds.Tables[0].Rows.Count; i++)
                {
                    dgvCWB.Rows.Insert(i, 1);
                    dgvCWB.Rows[i].Cells["CWB_ID"].Value = _ds.Tables[0].Rows[i]["CWB_ID"].ToString();
                    dgvCWB.Rows[i].Cells["CWB_RowNumber"].Value = _ds.Tables[0].Rows[i]["RowNumber"].ToString();
                    dgvCWB.Rows[i].Cells["CWB_CompanyName"].Value = _ds.Tables[0].Rows[i]["CWB_CompanyName"].ToString();
                    dgvCWB.Rows[i].Cells["CWB_City"].Value = _ds.Tables[0].Rows[i]["CWB_City"].ToString();
                    if (_ds.Tables[0].Rows[i]["CWB_StartDate"] != DBNull.Value)
                        dgvCWB.Rows[i].Cells["CWB_StartDate"].Value = Convert.ToDateTime(_ds.Tables[0].Rows[i]["CWB_StartDate"]).ToString("dd/MM/yyyy");
                    else
                        dgvCWB.Rows[i].Cells["CWB_StartDate"].Value = DateTime.MinValue;
                    if (_ds.Tables[0].Rows[i]["CWB_EndDate"] != DBNull.Value)
                        dgvCWB.Rows[i].Cells["CWB_EndDate"].Value = Convert.ToDateTime(_ds.Tables[0].Rows[i]["CWB_EndDate"]).ToString("dd/MM/yyyy");
                    else
                        dgvCWB.Rows[i].Cells["CWB_EndDate"].Value = DateTime.MinValue;
                    dgvCWB.Rows[i].Cells["CWB_Position"].Value = _ds.Tables[0].Rows[i]["CWB_Position"].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(UpdateUI.GetString("loi") + ":\n" + ex.Message + "\n" + UpdateUI.GetString("ghiloi"));
            }
        }
        private bool CheckValidCWB()
        {
            if (_CandidateInfo.ID == 0)
            {
                MessageBox.Show(UpdateUI.GetString("chualuuthongtincanhan"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return false;
            }
            if (UISetting.GetDate(mtxCWB_StartDate.Text) == DateTime.MinValue)
            {
                mtxCWB_StartDate.Focus();
                MessageBox.Show(UpdateUI.GetString("ngaybatdaukhonghople"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return false;
            }
            else
            {
                if (DateTime.Compare(UISetting.GetDate(mtxCWB_StartDate.Text), UISetting.GetDate(mtxCWB_EndDate.Text)) >= 0)
                {
                    mtxCWB_EndDate.Focus();
                    MessageBox.Show(UpdateUI.GetString("ngayketthucphaimuonhonngaybatdau"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return false;
                }
            }
            if (txtCWBCompanyName.Text.Trim().Length == 0)
            {
                txtCWBCompanyName.Focus();
                MessageBox.Show(UpdateUI.GetString("tencongtykhongduocdetrong"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return false;
            }
            if (txtCWBCity.Text.Trim().Length == 0)
            {
                txtCWBCity.Focus();
                MessageBox.Show(UpdateUI.GetString("tenthanhphokhongduocdetrong"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return false;
            }
            if (txtCWBPosition.Text.Trim().Length == 0)
            {
                txtCWBPosition.Focus();
                MessageBox.Show(UpdateUI.GetString("chuvukhongduocdetrong"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return false;
            }
            return true;
        }
        private void btnCWBNew_Click(object sender, EventArgs e)
        {
            _CWBInfo.ID = 0;
            mtxCWB_StartDate.Text = "";
            mtxCWB_EndDate.Text = "";
            txtCWBCompanyName.Text = "";
            txtCWBCity.Text = "";
            txtCWBPosition.Text = "";
            mtxCWB_StartDate.Focus();
        }
        private void btnCWBSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (CheckValidCWB())
                {
                    CWBIn();
                    if (_CWBInfo.ID > 0)//update
                    {
                        if (!listRole.Update)
                        {
                            MessageBox.Show(UpdateUI.GetString("khongcoquyencapnhat"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                        if (_wcfCWB.CWB_Exist(_CWBInfo.ID, _CWBInfo.CandidateID, txtCWBCompanyName.Text.Trim()))
                        {
                            MessageBox.Show(UpdateUI.GetString("datontai"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                        if (_wcfCWB.CWB_Update(_CWBInfo))
                        {
                            Program.taskbarNotifier.Show(UpdateUI.GetString("thongbao"), UpdateUI.GetString("capnhatthanhcong"), UIParamater.TIME_MOVE_UP, UIParamater.TIME_SHOW, UIParamater.TIME_MOVE_DOWN);
                            LoadData_CWB();
                        }
                        else
                            MessageBox.Show(UpdateUI.GetString("capnhatkhongthanhcong"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        if (!listRole.Create)
                        {
                            MessageBox.Show(UpdateUI.GetString("khongcoquyenthemmoi"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                        if (_wcfCWB.CWB_Exist(_CWBInfo.ID, _CWBInfo.CandidateID, txtCWBCompanyName.Text.Trim()))
                        {
                            MessageBox.Show(UpdateUI.GetString("datontai"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                        _CWBInfo.ID = _wcfCWB.CWB_Insert(_CWBInfo);
                        if (_CWBInfo.ID > 0)
                        {
                            Program.taskbarNotifier.Show(UpdateUI.GetString("thongbao"), UpdateUI.GetString("themmoithanhcong"), UIParamater.TIME_MOVE_UP, UIParamater.TIME_SHOW, UIParamater.TIME_MOVE_DOWN);
                            LoadData_CWB();
                        }
                        else
                            MessageBox.Show(UpdateUI.GetString("themmoikhongthanhcong"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    dgvCWB_CellClick(null, null);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(UpdateUI.GetString("loi") + ":\n" + ex.Message + "\n" + UpdateUI.GetString("ghiloi"));
            }
        }
        private void dgvCWB1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (!listRole.Delete)
            {
                MessageBox.Show(UpdateUI.GetString("khongcoquyenxoa"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (e.RowIndex < 0 || e.ColumnIndex !=
                    dgvCWB.Columns["CWB_Command"].Index) return;
            int CWBID = Convert.ToInt32(dgvCWB.CurrentRow.Cells["CWB_ID"].Value);
            if (MessageBox.Show(UpdateUI.GetString("bancochacchanxoa"), UIParamater.TitleProject, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                if (_wcfCWB.CWB_Delete(CWBID))
                {
                    Program.taskbarNotifier.Show(UIParamater.TitleProject, UpdateUI.GetString("xoathanhcong"), UIParamater.TIME_MOVE_UP, UIParamater.TIME_SHOW, UIParamater.TIME_MOVE_DOWN);
                    LoadData_CWB();
                }
                else
                {
                    MessageBox.Show(UpdateUI.GetString("xoakhongthanhcong"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            dgvCWB_CellClick(null, null);
        }
        private void dgvCWB_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dgvCWB.SelectedRows.Count > 0)
            {
                int CWBID = Convert.ToInt32(dgvCWB.CurrentRow.Cells["CWB_ID"].Value);
                _CWBInfo.ID = CWBID;
                ReadFromdgvCWB();
                CWBOut();
            }
        }
        private void ReadFromdgvCWB()
        {

            _CWBInfo.CompanyName = dgvCWB.CurrentRow.Cells["CWB_CompanyName"].Value.ToString();
            _CWBInfo.Position = dgvCWB.CurrentRow.Cells["CWB_Position"].Value.ToString();
            _CWBInfo.StartDate = dgvCWB.CurrentRow.Cells["CWB_StartDate"].Value == DBNull.Value ? DateTime.MinValue :
               UISetting.GetDate(dgvCWB.CurrentRow.Cells["CWB_StartDate"].Value.ToString());
            _CWBInfo.EndDate = dgvCWB.CurrentRow.Cells["CWB_EndDate"].Value == DBNull.Value ? DateTime.MinValue :
                UISetting.GetDate(dgvCWB.CurrentRow.Cells["CWB_EndDate"].Value.ToString());
            _CWBInfo.City = dgvCWB.CurrentRow.Cells["CWB_City"].Value.ToString();
        }
        private void dgvCWB_SelectionChanged(object sender, EventArgs e)
        {
            if (dgvCWB.SelectedRows.Count > 0)
            {
                int CWBID = dgvCWB.CurrentRow.Cells["CWB_ID"].Value == null ? 0 : Convert.ToInt32(dgvCWB.CurrentRow.Cells["CWB_ID"].Value);
                if (CWBID > 0)
                {
                    _CWBInfo.ID = CWBID;
                    ReadFromdgvCWB();
                }
            }
            else
            {
                _CWBInfo.ID = 0;
                _CWBInfo.CompanyName = "";
                _CWBInfo.Position = "";
                _CWBInfo.StartDate = DateTime.MinValue;
                _CWBInfo.EndDate = DateTime.MinValue;
                _CWBInfo.City = "";
            }
            CWBOut();
        }
        private void CWBIn()
        {
            _CWBInfo.CandidateID = _CandidateInfo.ID;
            _CWBInfo.CompanyName = txtCWBCompanyName.Text;
            _CWBInfo.Position = txtCWBPosition.Text;
            _CWBInfo.StartDate = UISetting.GetDate(mtxCWB_StartDate.Text);
            _CWBInfo.EndDate = UISetting.GetDate(mtxCWB_EndDate.Text);
            _CWBInfo.City = txtCWBCity.Text;
        }
        private void CWBOut()
        {
            txtCWBCompanyName.Text = _CWBInfo.CompanyName;
            txtCWBPosition.Text = _CWBInfo.Position;
            mtxCWB_StartDate.Text = _CWBInfo.StartDate == DateTime.MinValue ? "" : Convert.ToDateTime(_CWBInfo.StartDate).ToString("dd/MM/yyyy");
            mtxCWB_EndDate.Text = _CWBInfo.EndDate == DateTime.MinValue ? "" : Convert.ToDateTime(_CWBInfo.EndDate).ToString("dd/MM/yyyy");
            txtCWBCity.Text = _CWBInfo.City;
        }

        #endregion

        #region CFamily (Family)

        int itemCount_CFamily = 0;
        int currPage_CFamily = 0;
        private void LoadData_CFamily()
        {
            DataSet _ds = _wcfCFamily.CFamily_GetList(out itemCount_CFamily, _CandidateInfo.ID, currPage_CFamily, pageSize);
            dgvCFamily.Rows.Clear();
            for (int i = 0; i < _ds.Tables[0].Rows.Count; i++)
            {
                dgvCFamily.Rows.Insert(i, 1);
                dgvCFamily.Rows[i].Cells["CFamily_ID"].Value = _ds.Tables[0].Rows[i]["CFamily_ID"].ToString();
                dgvCFamily.Rows[i].Cells["CFamily_RowNumber"].Value = _ds.Tables[0].Rows[i]["RowNumber"].ToString();
                dgvCFamily.Rows[i].Cells["CFamily_Name"].Value = _ds.Tables[0].Rows[i]["CFamily_Name"].ToString();
                if (_ds.Tables[0].Rows[i]["CFamily_DOB"] != DBNull.Value)
                    dgvCFamily.Rows[i].Cells["CFamily_DOB"].Value = Convert.ToDateTime(_ds.Tables[0].Rows[i]["CFamily_DOB"]).ToString("dd/MM/yyyy");
                else
                    dgvCFamily.Rows[i].Cells["CFamily_DOB"].Value = DateTime.MinValue;
                dgvCFamily.Rows[i].Cells["CFamily_Relationship"].Value = _ds.Tables[0].Rows[i]["CFamily_Relationship"].ToString();
                dgvCFamily.Rows[i].Cells["CFamily_Age"].Value = _ds.Tables[0].Rows[i]["CFamily_Age"].ToString();
                dgvCFamily.Rows[i].Cells["CFamily_Employment"].Value = _ds.Tables[0].Rows[i]["CFamily_Employment"].ToString();



                dgvCFamily.Rows[i].Cells["CFamily_Address"].Value = _ds.Tables[0].Rows[i]["CFamily_Address"].ToString();

                if (_ds.Tables[0].Rows[i]["CFamily_IsDependent"] != DBNull.Value)
                    dgvCFamily.Rows[i].Cells["CFamily_IsDependent"].Value = Convert.ToBoolean(_ds.Tables[0].Rows[i]["CFamily_IsDependent"]);
                else
                    dgvCFamily.Rows[i].Cells["CFamily_IsDependent"].Value = false;
            }
        }
        private bool CheckValidCFamily()
        {
            if (_CandidateInfo.ID == 0)
            {
                MessageBox.Show(UpdateUI.GetString("chualuuthongtincanhan"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);

                return false;
            }
            if (txtCFamily_Name.Text.Trim().Length == 0)
            {
                txtCFamily_Name.Focus();
                MessageBox.Show(UpdateUI.GetString("tenkhongduocdetrong"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return false;
            }
            if (UISetting.GetIntNo(txtCFamily_Age.Text) == 0)
            {
                txtCFamily_Age.Focus();
                MessageBox.Show(UpdateUI.GetString("tuoikhonghople"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return false;
            }
            return true;
        }
        private void btnCFamilyNew_Click(object sender, EventArgs e)
        {
            _CFamilyInfo.ID = 0;
            txtCFamily_Name.Text = "";
            mtxCFamily_DOB.Text = "";
            txtCFamily_Relationship.Text = "";
            txtCFamily_Age.Text = "";
            txtCFamily_Employment.Text = "";
            txtCFamily_Address.Text = "";
            rdnCFamily_IsDependentY.Checked = false;
            rdnCFamily_IsDependentN.Checked = false;
            txtCFamily_Name.Focus();
        }
        private void btnCFamilySave_Click(object sender, EventArgs e)
        {
            if (CheckValidCFamily())
            {
                CFamilyIn();
                if (_CFamilyInfo.ID > 0)//update
                {
                    if (!listRole.Update)
                    {
                        MessageBox.Show(UpdateUI.GetString("khongcoquyencapnhat"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);

                        return;
                    }
                    if (_wcfCFamily.CFamily_Exist(_CFamilyInfo.ID, _CFamilyInfo.CandidateID, txtCFamily_Name.Text.Trim()))
                    {
                        MessageBox.Show(UpdateUI.GetString("datontai"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    if (_wcfCFamily.CFamily_Update(_CFamilyInfo))
                    {
                        Program.taskbarNotifier.Show(UpdateUI.GetString("thongbao"), UpdateUI.GetString("capnhatthanhcong"), UIParamater.TIME_MOVE_UP, UIParamater.TIME_SHOW, UIParamater.TIME_MOVE_DOWN);
                        LoadData_CFamily();
                    }
                    else
                        MessageBox.Show(UpdateUI.GetString("capnhatkhongthanhcong"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    if (!listRole.Create)
                    {
                        MessageBox.Show(UpdateUI.GetString("khongcoquyenthemmoi"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    if (_wcfCFamily.CFamily_Exist(_CFamilyInfo.ID, _CFamilyInfo.CandidateID, txtCFamily_Name.Text.Trim()))
                    {
                        MessageBox.Show(UpdateUI.GetString("datontai"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    _CFamilyInfo.ID = _wcfCFamily.CFamily_Insert(_CFamilyInfo);
                    if (_CFamilyInfo.ID > 0)
                    {
                        Program.taskbarNotifier.Show(UpdateUI.GetString("thongbao"), UpdateUI.GetString("themmoithanhcong"), UIParamater.TIME_MOVE_UP, UIParamater.TIME_SHOW, UIParamater.TIME_MOVE_DOWN);
                        LoadData_CFamily();
                    }
                    else
                        MessageBox.Show(UpdateUI.GetString("themmoikhongthanhcong"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                dgvCFamily_CellClick(null, null);
            }
        }
        private void dgvCFamily1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (!listRole.Delete)
            {
                MessageBox.Show(UpdateUI.GetString("khongcoquyenxoa"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (e.RowIndex < 0 || e.ColumnIndex !=
                    dgvCFamily.Columns["CFamily_Command"].Index) return;
            int CFamilyID = Convert.ToInt32(dgvCFamily.CurrentRow.Cells["CFamily_ID"].Value);
            if (MessageBox.Show(UpdateUI.GetString("bancochacchanxoa"), UIParamater.TitleProject, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                if (_wcfCFamily.CFamily_Delete(CFamilyID))
                {
                    Program.taskbarNotifier.Show(UIParamater.TitleProject, UpdateUI.GetString("xoathanhcong"), UIParamater.TIME_MOVE_UP, UIParamater.TIME_SHOW, UIParamater.TIME_MOVE_DOWN);
                    LoadData_CFamily();
                }
                else
                {
                    MessageBox.Show(UpdateUI.GetString("xoakhongthanhcong"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            dgvCFamily_CellClick(null, null);
        }
        private void dgvCFamily_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dgvCFamily.SelectedRows.Count > 0)
            {
                int CFamilyID = Convert.ToInt32(dgvCFamily.CurrentRow.Cells["CFamily_ID"].Value);
                _CFamilyInfo.ID = CFamilyID;
                ReadFromdgvCFamily();
                CFamilyOut();
            }
        }
        private void ReadFromdgvCFamily()
        {

            _CFamilyInfo.Name = dgvCFamily.CurrentRow.Cells["CFamily_Name"].Value.ToString();
            _CFamilyInfo.DOB = Convert.ToDateTime(dgvCFamily.CurrentRow.Cells["CFamily_DOB"].Value);
            _CFamilyInfo.Relationship = dgvCFamily.CurrentRow.Cells["CFamily_Relationship"].Value.ToString();
            _CFamilyInfo.Age = Convert.ToInt32(dgvCFamily.CurrentRow.Cells["CFamily_Age"].Value);
            _CFamilyInfo.Employment = dgvCFamily.CurrentRow.Cells["CFamily_Employment"].Value.ToString();
            _CFamilyInfo.Address = dgvCFamily.CurrentRow.Cells["CFamily_Address"].Value.ToString();
            _CFamilyInfo.IsDependent = Convert.ToBoolean(dgvCFamily.CurrentRow.Cells["CFamily_IsDependent"].Value);

        }
        private void dgvCFamily_SelectionChanged(object sender, EventArgs e)
        {
            if (dgvCFamily.SelectedRows.Count > 0)
            {
                int CFamilyID = dgvCFamily.CurrentRow.Cells["CFamily_ID"].Value == null ? 0 : Convert.ToInt32(dgvCFamily.CurrentRow.Cells["CFamily_ID"].Value);
                if (CFamilyID > 0)
                {
                    _CFamilyInfo.ID = CFamilyID;
                    ReadFromdgvCFamily();
                }
            }
            else
            {
                _CFamilyInfo.ID = 0;
                _CFamilyInfo.Name = "";
                _CFamilyInfo.DOB = DateTime.MinValue;
                _CFamilyInfo.Relationship = "";
                _CFamilyInfo.Age = 0;
                _CFamilyInfo.Employment = "";
                _CFamilyInfo.Address = "";
                _CFamilyInfo.IsDependent = false;
            }
            CFamilyOut();
        }
        private void CFamilyIn()
        {
            _CFamilyInfo.CandidateID = _CandidateInfo.ID;
            _CFamilyInfo.Name = txtCFamily_Name.Text;
            _CFamilyInfo.DOB = UISetting.GetDate(mtxCFamily_DOB.Text);
            _CFamilyInfo.Relationship = txtCFamily_Relationship.Text;
            _CFamilyInfo.Age = UISetting.GetIntNo(txtCFamily_Age.Text);
            _CFamilyInfo.Employment = txtCFamily_Employment.Text;
            _CFamilyInfo.Address = txtCFamily_Address.Text;
            _CFamilyInfo.IsDependent = rdnCFamily_IsDependentY.Checked;
        }
        private void CFamilyOut()
        {
            txtCFamily_Name.Text = _CFamilyInfo.Name;
            mtxCFamily_DOB.Text = _CFamilyInfo.DOB == DateTime.MinValue ? "" : Convert.ToDateTime(_CFamilyInfo.DOB).ToString("dd/MM/yyyy");
            txtCFamily_Relationship.Text = _CFamilyInfo.Relationship;
            txtCFamily_Age.Text = _CFamilyInfo.Age.ToString();
            txtCFamily_Employment.Text = _CFamilyInfo.Employment;
            txtCFamily_Address.Text = _CFamilyInfo.Address;
            rdnCFamily_IsDependentY.Checked = _CFamilyInfo.IsDependent;
            rdnCFamily_IsDependentN.Checked = !rdnCFamily_IsDependentY.Checked;
        }
        private void mtxCFamily_DOB_Leave(object sender, EventArgs e)
        {
            if (UISetting.GetDate(mtxCFamily_DOB.Text) != DateTime.MinValue)
            {
                txtCFamily_Age.ReadOnly = true;
                int _BirthYear = UISetting.GetDate(mtxCFamily_DOB.Text).Year;
                int _NowYear = DateTime.Now.Year;
                txtCFamily_Age.Text = (_NowYear - _BirthYear).ToString();
                txtCFamily_Age.ReadOnly = true;
                txtCFamily_Age.BackColor = tpgPersonal.BackColor;
            }
            else
            {
                txtCFamily_Age.Text = "0";
                txtCFamily_Age.ReadOnly = false;
                txtCFamily_Age.BackColor = Color.White;
            }
        }
        #endregion

        #region CLanguage (Language)

        int itemCount_CLanguage = 0;
        int currPage_CLanguage = 0;
        private void LoadData_CLanguage()
        {
            try
            {
                DataSet _ds = _wcfCLanguage.CLanguage_GetList(out itemCount_CLanguage, _CandidateInfo.ID, currPage_CLanguage, pageSize);
                dgvCLanguage.Rows.Clear();
                for (int i = 0; i < _ds.Tables[0].Rows.Count; i++)
                {
                    dgvCLanguage.Rows.Insert(i, 1);
                    dgvCLanguage.Rows[i].Cells["CLanguage_ID"].Value = _ds.Tables[0].Rows[i]["CLanguage_ID"].ToString();
                    dgvCLanguage.Rows[i].Cells["CLanguage_RowNumber"].Value = _ds.Tables[0].Rows[i]["RowNumber"].ToString();
                    dgvCLanguage.Rows[i].Cells["CLanguage_Name"].Value = _ds.Tables[0].Rows[i]["CLanguage_Name"].ToString();
                    dgvCLanguage.Rows[i].Cells["Clanguage_SelfRating"].Value = _ds.Tables[0].Rows[i]["Clanguage_SelfRating"].ToString();
                    dgvCLanguage.Rows[i].Cells["Clanguage_CommentsOfInterview"].Value = _ds.Tables[0].Rows[i]["Clanguage_CommentsOfInterview"].ToString();

                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(UpdateUI.GetString("loi") + ":\n" + ex.Message + "\n" + UpdateUI.GetString("ghiloi"));
            }
        }
        private bool CheckValidCLanguage()
        {
            if (txtCode.Text.Trim().Length == 0)
            {
                tabCandidate.SelectedTab = tpgPersonal;
                txtCode.Focus();
                MessageBox.Show(UpdateUI.GetString("masokhongduoctrong"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return false;
            }
            if (txtLastName.Text.Trim().Length == 0)
            {
                tabCandidate.SelectedTab = tpgPersonal;
                txtLastName.Focus();
                MessageBox.Show(UpdateUI.GetString("hotrong"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return false;
            }
            if (txtFirstName.Text.Trim().Length == 0)
            {
                tabCandidate.SelectedTab = tpgPersonal;
                txtFirstName.Focus();
                MessageBox.Show(UpdateUI.GetString("tentrong"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return false;
            }

            if (!rdnMale.Checked && !rdnFemale.Checked)
            {
                tabCandidate.SelectedTab = tpgPersonal;
                MessageBox.Show(UpdateUI.GetString("chuachongioitinh"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return false;
            }
            if (UISetting.GetDate(mtxBirthday.Text) == DateTime.MinValue)
            {
                tabCandidate.SelectedTab = tpgPersonal;
                mtxBirthday.Focus();
                MessageBox.Show(UpdateUI.GetString("ngaysinhkhonghople"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return false;
            }
            if (UISetting.GetDate(mtxIDCardIssueDate.Text) != DateTime.MinValue)
            {
                if (DateTime.Compare(UISetting.GetDate(mtxBirthday.Text), UISetting.GetDate(mtxIDCardIssueDate.Text)) >= 0)
                {
                    tabCandidate.SelectedTab = tpgPersonal;
                    mtxIDCardIssueDate.Focus();
                    MessageBox.Show(UpdateUI.GetString("ngaycapphaimuonhonnaysinh"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return false;
                }
            }
            if (UISetting.GetDate(mtxDate.Text) == DateTime.MinValue)
            {
                tabCandidate.SelectedTab = tpgPersonal;
                mtxDate.Focus();
                MessageBox.Show(UpdateUI.GetString("ngaynophosokhonghople"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return false;
            }
            else
            {
                if (DateTime.Compare(UISetting.GetDate(mtxBirthday.Text), UISetting.GetDate(mtxDate.Text)) >= 0)
                {
                    tabCandidate.SelectedTab = tpgPersonal;
                    mtxDate.Focus();
                    MessageBox.Show(UpdateUI.GetString("ngaynopphaimuonhongaysinh"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return false;
                }

            }
            return true;
        }
        private void btnCLanguageNew_Click(object sender, EventArgs e)
        {
            _CLanguageInfo.ID = 0;
            txtCLanguage_Name.Text = "";
            mcbCLanguage_SelfRating.SelectedValue = "";
            mcbCLanguage_CommentsOfInterview.SelectedValue = "";
            txtCLanguage_Name.Focus();
        }
        private void btnCLanguageSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (CheckValidCLanguage())
                {
                    CLanguageIn();
                    if (_CLanguageInfo.ID > 0)//update
                    {
                        if (!listRole.Update)
                        {
                            MessageBox.Show(UpdateUI.GetString("khongcoquyencapnhat"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                        if (_wcfCLanguage.CLanguage_Exist(_CLanguageInfo.ID, _CLanguageInfo.CandidateID, txtCLanguage_Name.Text.Trim()))
                        {
                            MessageBox.Show(UpdateUI.GetString("datontai"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                        if (_wcfCLanguage.CLanguage_Update(_CLanguageInfo))
                        {
                            Program.taskbarNotifier.Show(UpdateUI.GetString("thongbao"), UpdateUI.GetString("capnhatthanhcong"), UIParamater.TIME_MOVE_UP, UIParamater.TIME_SHOW, UIParamater.TIME_MOVE_DOWN);
                            LoadData_CLanguage();
                        }
                        else
                            MessageBox.Show(UpdateUI.GetString("capnhatkhongthanhcong"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        if (!listRole.Create)
                        {
                            MessageBox.Show(UpdateUI.GetString("khongcoquyenthemmoi"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                        if (_wcfCLanguage.CLanguage_Exist(_CLanguageInfo.ID, _CLanguageInfo.CandidateID, txtCLanguage_Name.Text.Trim()))
                        {
                            MessageBox.Show(UpdateUI.GetString("datontai"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                        _CLanguageInfo.ID = _wcfCLanguage.CLanguage_Insert(_CLanguageInfo);
                        if (_CLanguageInfo.ID > 0)
                        {
                            Program.taskbarNotifier.Show(UpdateUI.GetString("thongbao"), UpdateUI.GetString("themmoithanhcong"), UIParamater.TIME_MOVE_UP, UIParamater.TIME_SHOW, UIParamater.TIME_MOVE_DOWN);
                            LoadData_CLanguage();
                        }
                        else
                            MessageBox.Show(UpdateUI.GetString("themmoikhongthanhcong"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    dgvCLanguage_CellClick(null, null);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(UpdateUI.GetString("loi") + ":\n" + ex.Message + "\n" + UpdateUI.GetString("ghiloi"));
            }
        }
        private void dgvCLanguage1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (!listRole.Delete)
            {
                MessageBox.Show(UpdateUI.GetString("khongcoquyenxoa"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (e.RowIndex < 0 || e.ColumnIndex !=
                    dgvCLanguage.Columns["CLanguage_Command"].Index) return;
            int CLanguageID = Convert.ToInt32(dgvCLanguage.CurrentRow.Cells["CLanguage_ID"].Value);
            if (MessageBox.Show(UpdateUI.GetString("bancochacchanxoa"), UIParamater.TitleProject, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                if (_wcfCLanguage.CLanguage_Delete(CLanguageID))
                {
                    Program.taskbarNotifier.Show(UIParamater.TitleProject, UpdateUI.GetString("xoathanhcong"), UIParamater.TIME_MOVE_UP, UIParamater.TIME_SHOW, UIParamater.TIME_MOVE_DOWN);
                    LoadData_CLanguage();
                }
                else
                {
                    MessageBox.Show(UpdateUI.GetString("xoakhongthanhcong"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            dgvCLanguage_CellClick(null, null);
        }
        private void dgvCLanguage_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dgvCLanguage.SelectedRows.Count > 0)
            {
                int CLanguageID = Convert.ToInt32(dgvCLanguage.CurrentRow.Cells["CLanguage_ID"].Value);
                _CLanguageInfo.ID = CLanguageID;
                ReadFromdgvCLanguage();
                CLanguageOut();
            }
        }
        private void ReadFromdgvCLanguage()
        {
            _CLanguageInfo.Name = dgvCLanguage.CurrentRow.Cells["CLanguage_Name"].Value.ToString();
            _CLanguageInfo.SelfRating = dgvCLanguage.CurrentRow.Cells["Clanguage_SelfRating"].Value.ToString();
            _CLanguageInfo.CommentsOfInterview = dgvCLanguage.CurrentRow.Cells["Clanguage_CommentsOfInterview"].Value.ToString();
        }
        private void dgvCLanguage_SelectionChanged(object sender, EventArgs e)
        {
            if (dgvCLanguage.SelectedRows.Count > 0)
            {
                int CLanguageID = dgvCLanguage.CurrentRow.Cells["CLanguage_ID"].Value == null ? 0 : Convert.ToInt32(dgvCLanguage.CurrentRow.Cells["CLanguage_ID"].Value);
                if (CLanguageID > 0)
                {
                    _CLanguageInfo.ID = CLanguageID;
                    ReadFromdgvCLanguage();
                }
            }
            else
            {
                _CLanguageInfo.ID = 0;
                _CLanguageInfo.Name = "";
                _CLanguageInfo.SelfRating = "";
                _CLanguageInfo.CommentsOfInterview = "";
            }
            CLanguageOut();
        }
        private void CLanguageIn()
        {
            _CLanguageInfo.CandidateID = _CandidateInfo.ID;
            _CLanguageInfo.Name = txtCLanguage_Name.Text;
            _CLanguageInfo.SelfRating = mcbCLanguage_SelfRating.SelectedValue.ToString();
            _CLanguageInfo.CommentsOfInterview = mcbCLanguage_CommentsOfInterview.SelectedValue.ToString();
        }
        private void CLanguageOut()
        {
            txtCLanguage_Name.Text = _CLanguageInfo.Name;
            mcbCLanguage_SelfRating.SelectedValue = _CLanguageInfo.SelfRating;
            mcbCLanguage_CommentsOfInterview.SelectedValue = _CLanguageInfo.CommentsOfInterview;
        }
        #endregion


        #region Form's Event

        void LoadLanguage()
        {
            if (this.Tag != null)
                this.Text = UpdateUI.GetString(this.Tag.ToString());
            UpdateUI.Load_ToolStrip(ref toolStrip1);
            UpdateUI.Load_TabControl1(ref tabCandidate);
            UpdateUI.Load_Panel(ref panel1);
            UpdateUI.Load_Panel(ref panel5);
            UpdateUI.Load_Panel(ref panel6);
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
            this.Dispose();
        }

        private void frmCandidate_FormClosing(object sender, FormClosingEventArgs e)
        {
            _wcfCandidate.Close();
            _wcfCC.Close();
            _wcfCCriteria.Close();
            _wcfCFamily.Close();
            _wcfCInterview.Close();
            _wcfCLanguage.Close();
            _wcfCWB.Close();
            this.DialogResult = dlgResult;
        }

        private void frmCandidate_KeyUp(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
                case Keys.Escape:
                    this.Dispose();
                    this.Close();
                    break;
                case Keys.F2:
                    btnNew_Click(null, null);
                    break;
                case Keys.F3:
                    if (btnSave.Enabled)
                        btnSave_Click(null, null);
                    break;
                case Keys.Enter:
                    if (!e.Alt && !e.Control)
                    {
                        this.ProcessTabKey(!e.Shift);
                        e.Handled = true;
                    }
                    break;
            }
        }
        private void rdnPartimeCourseN_CheckedChanged(object sender, EventArgs e)
        {
            if (rdnPartimeCourseN.Checked)
            {
                txtCourseTime.Text = "";
                txtCourseTime.BackColor = tpgPersonal.BackColor;
                txtCourseTime.ReadOnly = true;

                txtCourseName.Text = "";
                txtCourseName.BackColor = tpgPersonal.BackColor;
                txtCourseName.ReadOnly = true;
            }
        }

        private void rdnPartimeCourseY_CheckedChanged(object sender, EventArgs e)
        {
            if (rdnPartimeCourseY.Checked)
            {
                txtCourseTime.Text = "";
                txtCourseTime.BackColor = Color.White;
                txtCourseTime.ReadOnly = false;

                txtCourseName.Text = "";
                txtCourseName.BackColor = Color.White;
                txtCourseName.ReadOnly = false;
            }
        }

        private void rdnAcquaintanceN_CheckedChanged(object sender, EventArgs e)
        {
            if (rdnAcquaintanceN.Checked)
            {
                txtAcquaintanceName.Text = "";
                txtAcquaintanceName.BackColor = tpgPersonal.BackColor;
                txtAcquaintanceName.ReadOnly = true;
            }
        }

        private void rdnAcquaintanceY_CheckedChanged(object sender, EventArgs e)
        {
            if (rdnAcquaintanceY.Checked)
            {
                txtAcquaintanceName.Text = "";
                txtAcquaintanceName.BackColor = Color.White;
                txtAcquaintanceName.ReadOnly = false;
            }
        }
        #endregion

        private void frmCandidate_Load(object sender, EventArgs e)
        {
            if (dgvCC.Columns.Count > 0)
            {
                dgvCC.Columns["CC_RowNumber"].HeaderText = UpdateUI.GetString("stt");
                dgvCC.Columns["CC_AuthorityIssue"].HeaderText = UpdateUI.GetString("tentruong");
                dgvCC.Columns["CC_Command"].HeaderText = UpdateUI.GetString("lenh");
            }
            if (dgvCWB.Columns.Count > 0)
            {
                dgvCWB.Columns["CWB_RowNumber"].HeaderText = UpdateUI.GetString("stt");
                dgvCWB.Columns["CWB_CompanyName"].HeaderText = UpdateUI.GetString("congty");
                dgvCWB.Columns["CWB_Command"].HeaderText = UpdateUI.GetString("lenh");
            }
            if (dgvCFamily.Columns.Count > 0)
            {
                dgvCFamily.Columns["CFamily_RowNumber"].HeaderText = UpdateUI.GetString("stt");
                dgvCFamily.Columns["CFamily_Name"].HeaderText = UpdateUI.GetString("hovaten");
                dgvCFamily.Columns["CFamily_Command"].HeaderText = UpdateUI.GetString("lenh");
            }
            if (dgvCLanguage.Columns.Count > 0)
            {
                dgvCLanguage.Columns["CLanguage_RowNumber"].HeaderText = UpdateUI.GetString("stt");
                dgvCLanguage.Columns["CLanguage_Name"].HeaderText = UpdateUI.GetString("ngonngu");
                dgvCLanguage.Columns["CLanguage_Command"].HeaderText = UpdateUI.GetString("lenh");
            }
        }

    }
}
